#include "DTOFlightRelated.h"
#include "../../utils/Logger.h"

DTOFlightRelated::DTOFlightRelated(std::string& aDeserealizar): DTO(FLIGHT_RELATED){
	deserializar(aDeserealizar);
}

DTOFlightRelated::DTOFlightRelated(DTOFlight dtoFlight,flightRelatedRequestType actionToPerform)
: DTO(FLIGHT_RELATED),dtoFlight(dtoFlight),actionToPerform(actionToPerform)  {
}


DTOFlightRelated::~DTOFlightRelated() {
}

std::string DTOFlightRelated::serializar(){
	std::stringstream retorno;

	retorno << DTO::serializar();
	retorno << dtoFlight.getFlightId();
	retorno << PLANO_SEPARATOR;
	retorno << dtoFlight.getState();
	retorno << PLANO_SEPARATOR;
	retorno << UtilString::intToString(this->actionToPerform);


	return (retorno.str());
}
void DTOFlightRelated::deserializar(std::string& string){
	std::vector<std::string> valores;
	UtilString::splitWithSeparator(&valores,string,PLANO_SEPARATOR);

	DTOFlight dto(UtilString::stringToInt(valores[1]),UtilString::stringToInt(valores[2]));
	this->dtoFlight = dto;
	actionToPerform = (flightRelatedRequestType)UtilString::stringToInt(valores[3]);
}

DTOFlight DTOFlightRelated::getDtoFlight(){
	return (this->dtoFlight);
}


flightRelatedRequestType DTOFlightRelated::getActionToPerform(){
	return this->actionToPerform;
}

